/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */

package l1j.server.server.model.Instance;

import java.util.logging.Logger;

import l1j.server.server.serverpackets.S_Board;
import l1j.server.server.serverpackets.S_Board2;
import l1j.server.server.serverpackets.S_BoardClassRank;
import l1j.server.server.serverpackets.S_BoardEnchantRank;
import l1j.server.server.serverpackets.S_BoardRead;
import l1j.server.server.serverpackets.S_BoardRead2;
import l1j.server.server.templates.L1Npc;

public class L1BoardInstance extends L1NpcInstance {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Logger _log = Logger.getLogger(L1BoardInstance.class
			.getName());

	public L1BoardInstance(L1Npc template) {
		super(template);
	}

	@Override
	public void onAction(L1PcInstance player) {
		player.sendPackets(new S_Board(this));
	}

	public void onAction(L1PcInstance player, int number) {
		player.sendPackets(new S_Board(this, number));
	}

	public void onActionRead(L1PcInstance player, int number) {
		player.sendPackets(new S_BoardRead(number));
	}

	public void onAction(L1PcInstance player, int number, int npcid) {
		// TODO Auto-generated method stub
		if(npcid == 90011) {
			player.sendPackets(new S_BoardClassRank(this,player,number));
		} else if(npcid == 90012) {
			player.sendPackets(new S_BoardEnchantRank(this,player, number));
		/*} else if(npcid == 72222) {
			player.sendPackets(new S_BoardServerRank(this,number));*/
			
		} else if(npcid == 90013 
				|| npcid == 90014) { // notice board

			String table = "board";

			if (npcid == 90013) {
				table = "board_notice";
			} else if (npcid == 90014) {
				table = "board_tmp";
			}

			if (number > 0) {
				player.sendPackets(new S_BoardRead2(number, table));
			} else {
				player.sendPackets(new S_Board2(this, number, table));
			}
			
		} else {
			if(number > 0) {
				player.sendPackets(new S_BoardRead(number));
			} else {
				player.sendPackets(new S_Board(this,number));		
			}
		}
	}
}
